function [x,fval,residual,exitflag,output]=optim_fitsol(Param,xdata,ydata,yerr,LB,UB)
options=optimset('MaxIter',500,'TolFun',1e-8,'Display','off','TolX',1e-8,'MaxFunEvals',2000);
[x,fval,residual,exitflag,output]=lsqcurvefit(@nestedfun,Param,xdata,(ydata./yerr),LB,UB,options);
    function y=nestedfun(Param,xdata)
        C=Param(1);
        qc=Param(2);
        Z=Param(3);
        C_bulk=Param(4);
        qz=xdata;
        Energy=8.0;
        Attl= 988.926e4; % Attenuation length in unit of Angstrom for water @ 8.0 keV
        mu=1/Attl;
        lambda=1.5498; % in unit of Angstrom
        beta=mu*lambda/4/pi;
        
        T=Transmission(qz,qc,beta,lambda);
        D=fitsubphase(qz,qc,Energy,Attl);
        y=C*T.*exp(-Z./D)+C_bulk*T.*D;
        y=(y./yerr);
    end
end